﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;

namespace PokemonRuby
{
    public class Pokemon
    {
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private int hp;

        public int Hp
        {
            get { return hp; }
            set { hp = value; }
        }
        private string type;
        private int sex;
        private int attack;

        public int Attack
        {
            get { return attack; }
            set { attack = value; }
        }
        private int defense;

        public int Defense
        {
            get { return defense; }
            set { defense = value; }
        }
        private int sp_attack;
        private int sp_defense;
        private int speed;
        private int exp;
        private int level;

        public int Level
        {
            get { return level; }
            set { level = value; }
        }

        private string image;

        Hashtable htPokemon = new Hashtable();
        Hashtable htLoaiVoCong = new Hashtable();
        public Hashtable LoadPropertiesOfCharacter()
        {
            // lv 5, hp 100, type Electronic
            //
            string fileName = Path.Combine(GlobalVariable.appPath + "\\PokemonData\\1");
            StreamReader sr = File.OpenText(fileName);
            string s = null;
            string[] sar = null;

            s = sr.ReadLine();
            while (s != null)
            {
                sar = s.Split(':');
                htPokemon.Add(sar[0], sar[1]);
                s = sr.ReadLine();
            }
            return htPokemon;
        }
        public Hashtable LoadLoaiVoCong(string file)
        {
            // tackle:100
            htLoaiVoCong = new Hashtable();
            string fileName = Path.Combine(GlobalVariable.appPath + "\\PokemonData\\" + file);
            StreamReader sr = File.OpenText(fileName);
            string s = null;
            string[] sar = null;

            s = sr.ReadLine();
            while (s != null)
            {
                sar = s.Split(':');
                htLoaiVoCong.Add(sar[0], sar[1]);
                s = sr.ReadLine();
            }
            return htLoaiVoCong;
        }
        public void getPropertiesOfCharacter(string namePokemon)
        {
            this.LoadPropertiesOfCharacter();
            string str = (string)htPokemon[namePokemon];
            string[] sar = null;
            sar = str.Split(',');
            this.level = int.Parse(sar[0]);
            this.hp = int.Parse(sar[1]);
            this.defense = int.Parse(sar[2]);
            this.type = sar[3];
        }
        public int getMotLoaiVoCong(string tenLoaiVoCong, Pokemon pkm)
        {
            this.LoadLoaiVoCong("Pikachu");
            string str = (string)htLoaiVoCong[tenLoaiVoCong];
            string[] sar = null;
            sar = str.Split(',');
            pkm.attack = int.Parse(sar[0]);
            return pkm.attack;
        }
    }
}
